package com.applet.applet_shangcheng.dao;

import com.applet.applet_shangcheng.entity.Address;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AddressMapper {
    @Select({
            "select id,username,provinceid,cityid,areaid,phone,address,contact,is_default,alias from tb_address where username=#{username}"
    })
    List<Address> findByAddress(@Param("username") String username);

    @Delete({
            "delete from tb_address where id=#{id}"
    })
    int deleteAddress(@Param("id") int id);
    @Update({
            "update tb_address set username=#{username},provinceid=#{provinceid},cityid=#{cityid},areaid=#{areaid},phone=#{phone},address=#{address},contact=#{contact},is_default=#{isDefault},alias=#{alias} where id=#{id}"
    })
    int updateAddress(Address address);
    @Insert({
            "insert into tb_address (username,provinceid,cityid,areaid,phone,address,contact,is_default,alias) values (#{username},#{provinceid},#{cityid},#{areaid},#{phone},#{address},#{contact},#{isDefault},#{alias})"
    })
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertAddress(Address address);
}

